//
//  wodeshoucangViewController.m
//  个人信息
//
//  Created by IOSchengxuyuan on 15/12/8.
//  Copyright © 2015年 com.ppfur. All rights reserved.
//

#import "wodeshoucangViewController.h"


@interface wodeshoucangViewController (){
    float width,height;
    float aa,bb;
}
@property (nonatomic ,strong) UICollectionView *toucollectionView;
@end

@implementation wodeshoucangViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    width=[UIScreen mainScreen].bounds.size.width;
    height=[UIScreen mainScreen].bounds.size.height;
    _cc.dataSource=self;
    _cc.delegate=self;
    aa=width/320;
    bb=height/568;
    _cc.scrollEnabled=NO;
    _cc.backgroundColor=[UIColor groupTableViewBackgroundColor];
    _cc.frame=CGRectMake(0, 0, width, height);
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    /* 更改item 大小 默认（50 * 50） */
    flowLayout.itemSize = CGSizeMake(w / 2-20, w / 2 -20);
    /* 设置item 上下之间的距离（最小值）*/
    flowLayout.minimumLineSpacing = 5;
    /* 设置item 左右之间的距离（最小值） */
    flowLayout.minimumInteritemSpacing = 5;
    /* 设置距四边地距离 */
    flowLayout.sectionInset = UIEdgeInsetsMake(15, 15, 15, 15);
    /* 创建对象 */
    self.toucollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) collectionViewLayout:flowLayout];
    /* 背景颜色默认是黑色 */
    /* 两个协议 */
    self.toucollectionView.delegate = self;
    self.toucollectionView.dataSource =self;
    self.toucollectionView.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    
    return 1;
    
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 4;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString *cell=@"cell";
    
    UICollectionViewCell *celll=[collectionView dequeueReusableCellWithReuseIdentifier:cell forIndexPath:indexPath];
    
    celll.backgroundColor=[UIColor whiteColor];
    
    UIImageView*ii=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 152*aa, 160)];
    ii.image=[UIImage imageNamed:@"list2.jpg"];
    UILabel*ll1=[[UILabel alloc] initWithFrame:CGRectMake(5*aa, 155, 120*aa, 20*bb)];
    ll1.text=@"皮草简介 皮草简介";
    ll1.font=[UIFont systemFontOfSize:12.0f];
    [celll addSubview:ll1];
    UILabel*ll2=[[UILabel alloc] initWithFrame:CGRectMake(5*aa, 180, 120*aa, 20*bb)];
    ll2.text=@"¥12340.00";
    ll2.font=[UIFont systemFontOfSize:11.0f];
    ll2.textColor=[UIColor redColor];
    [celll addSubview:ll2];
    UILabel*ll3=[[UILabel alloc] initWithFrame:CGRectMake(120*aa, 180, 20*aa, 20*bb)];
    ll3.text=@"2";
    ll3.font=[UIFont systemFontOfSize:11.0f];
    ll3.textColor=[UIColor redColor];
    [celll addSubview:ll3];
    UIButton*bb2=[[UIButton alloc] initWithFrame:CGRectMake(133*aa, 183,15*aa, 13*bb)];
    [bb2 setImage:[UIImage imageNamed:@"sc1.jpg"] forState:UIControlStateNormal];
    [celll addSubview:bb2];
    UIButton*bb3=[[UIButton alloc] initWithFrame:CGRectMake(0, 130, 152*aa, 22)];
    bb3.backgroundColor=[UIColor blackColor];
    bb3.alpha=0.7;
    [bb3 setTitle:@"更多优惠>" forState:UIControlStateNormal];
    [bb3 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    bb3.titleLabel.font=[UIFont systemFontOfSize:11.0f];
     
    [ii addSubview:bb3];
    
//    UILabel *bb=[[UILabel alloc]initWithFrame:CGRectMake(20, 0, 20, 20)];
    
//    bb.text=@"a";
//    
//    [celll addSubview:bb];
   
    [celll addSubview:ii];
    return celll;
    
    
}
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    
    CGSize cc = CGSizeMake(152*aa, 200);
    
    return cc;
}


-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
    
    return 5;
}

-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    
    return 5;
    
    
}
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    
    
    return UIEdgeInsetsMake(5*bb, 5*aa, 80*bb,5*aa);//上左下右
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
